﻿using System;
using System.Collections.Generic;
using System.Text;
using IDotNet.MapLibs.BMap.Model;

namespace IDotNet.MapLibs.Model
{
    public class BMapGeocoderResultModel : BMapBaseResultModel, IGeocoderResultModel
    {

        public BMapGeocoderResultInfo result { get; set; }

        public int ErrorCode
        {
            get { return status; }
        }

        public PointModel AddressLocaltion
        {
            get
            {
                if (result != null)
                {
                    return result.location;
                }
                return null;
            }
        }

        public string Msg
        {
            get
            {
                if (status == 0)
                {
                    return "正常";
                }
                if (status == 1)
                {
                    return "服务器内部错误";
                }
                if (status == 2)
                {
                    return "请求参数非法";
                }
                if (status == 3)
                {
                    return "权限校验失败";
                }
                if (status == 4)
                {
                    return "配额校验失败";
                }
                if (status == 5)
                {
                    return "ak不存在或者非法";
                }
                if (status == 101)
                {
                    return "服务禁用";
                }
                if (status == 102)
                {
                    return "不通过白名单或者安全码不对";
                }
                if (status >= 200 && status < 300)
                {
                    return "无权限";
                }
                if (status >= 300 && status < 400)
                {
                    return "配额错误";
                }
                return "未知错误，请联系管理员！";

            }
        }

    }

    public class BMapGeocoderResultInfo
    {
        /// <summary>
        /// 经纬度坐标
        /// </summary>
        public PointModel location { get; set; }

        /// <summary>
        /// 位置的附加信息，是否精确查找。1为精确查找，0为不精确
        /// </summary>
        public int precise { get; set; }

        /// <summary>
        /// 可信度
        /// </summary>
        public int confidence { get; set; }

        /// <summary>
        /// 地址类型
        /// </summary>
        public string level { get; set; }
    }

    public class BMapGeocoderLocationResultModel : BMapBaseResultModel, IGeocoderLocationResultModel
    {

        public BMapGeocoderResultInfo result { get; set; }

        public int ErrorCode
        {
            get { return status; }
        }

        public PointModel AddressLocaltion
        {
            get
            {
                if (result != null)
                {
                    return result.location;
                }
                return null;
            }
        }

        public string Msg
        {
            get
            {
                if (status == 0)
                {
                    return "正常";
                }
                if (status == 1)
                {
                    return "服务器内部错误";
                }
                if (status == 2)
                {
                    return "请求参数非法";
                }
                if (status == 3)
                {
                    return "权限校验失败";
                }
                if (status == 4)
                {
                    return "配额校验失败";
                }
                if (status == 5)
                {
                    return "ak不存在或者非法";
                }
                if (status == 101)
                {
                    return "服务禁用";
                }
                if (status == 102)
                {
                    return "不通过白名单或者安全码不对";
                }
                if (status >= 200 && status < 300)
                {
                    return "无权限";
                }
                if (status >= 300 && status < 400)
                {
                    return "配额错误";
                }
                return "未知错误，请联系管理员！";

            }
        }



        public AddressComponent AddressComponent
        {
            get; set;
        }
    }
}
